package org.example.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.entity.SysMenu;
import org.example.mapper.AddMenuMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AddMenuService {
    @Resource
    private AddMenuMapper addMenuMapper;

    public boolean addMenu(SysMenu sysMenu){

        QueryWrapper<SysMenu> queryWrapper=new QueryWrapper<>();

        queryWrapper.eq("title",sysMenu.getTitle());

        SysMenu sysMenu1 = addMenuMapper.selectOne(queryWrapper);

        if(sysMenu1==null){
            addMenuMapper.insert(sysMenu);
            return true;
        }else {
            return false;
        }

    }
}
